package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.MaintainFeeAttachBiz;
import com.egao.orderB.entity.MaintainFeeAttach;
import com.egao.orderB.service.MaintainFeeAttachService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//import com.egao.orderB.mapper.MaintainFeeAttachMapper;
//import javax.transaction.Transactional;

/**
 * 附加费维护服务实现类
 * @author : Doman
 * @date : 2020-06-15 15:18:10
 * @version ：1.0
 */
@Service
public class MaintainFeeAttachServiceImpl /*extends ServiceImpl<MaintainFeeAttachMapper, MaintainFeeAttach> */implements MaintainFeeAttachService {

	@Autowired
	private MaintainFeeAttachBiz maintainFeeAttachBiz;

    /**
    @Override
    public PageResult<MaintainFeeAttach> listPage(PageParam<MaintainFeeAttach> page) {
        List<MaintainFeeAttach> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<MaintainFeeAttach> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, MaintainFeeAttach maintainFeeAttach, User loginUser)  throws Exception{
        return maintainFeeAttachBiz.list(page,maintainFeeAttach,loginUser);
    }

    @Override
    public JsonResult list(MaintainFeeAttach maintainFeeAttach, User loginUser) {
//        List<MaintainFeeAttach> list = maintainFeeAttachBiz.list(maintainFeeAttach,loginUser);
//        for(MaintainFeeAttach f: list) {
//            System.out.println(f.getPinyin()+"=== ");
//            if(f.getPinyin()==null || f.getPinyin().equals(""))
//                maintainFeeAttachBiz.update(f,loginUser);
//        }
        return JsonResult.ok().setData(maintainFeeAttachBiz.list(maintainFeeAttach,loginUser));
    }

    @Override
    public JsonResult getById(MaintainFeeAttach maintainFeeAttach) {
        return JsonResult.ok().setData(maintainFeeAttachBiz.getById(maintainFeeAttach));
    }

    @Override
    public JsonResult save(MaintainFeeAttach maintainFeeAttach, User loginUser) {
        if (maintainFeeAttachBiz.save(maintainFeeAttach, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Override
    public JsonResult update(MaintainFeeAttach maintainFeeAttach, User loginUser) {
        if (maintainFeeAttachBiz.update(maintainFeeAttach, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(MaintainFeeAttach maintainFeeAttach, User loginUser) {
        if (maintainFeeAttachBiz.remove(maintainFeeAttach, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
